/**
 * 
 */
package com.et114.modules.system.dictionary.cells;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.extremecomponents.table.bean.Column;
import org.extremecomponents.table.cell.Cell;
import org.extremecomponents.table.core.TableModel;
import org.extremecomponents.table.limit.Limit;
import org.extremecomponents.table.limit.Sort;
import org.extremecomponents.util.HtmlBuilder;
   
/**
 * @author guanhw
 */
public class DicTypeModHrefCell implements Cell {
	protected  Log logger = LogFactory.getLog( this.getClass ( ) );
	/**
	 * 
	 */
	public DicTypeModHrefCell ( ) {
		// TODO Auto-generated constructor stub
	}
	
	/* (non-Javadoc)
	 * @see org.extremecomponents.table.cell.Cell#getExportDisplay(org.extremecomponents.table.core.TableModel, org.extremecomponents.table.bean.Column)
	 */
	public String getExportDisplay ( TableModel arg0 , Column arg1 ) {
		// TODO Auto-generated method stub
		return null;
	}
	
	/* (non-Javadoc)
	 * @see org.extremecomponents.table.cell.Cell#getHtmlDisplay(org.extremecomponents.table.core.TableModel, org.extremecomponents.table.bean.Column)
	 */
	public String getHtmlDisplay ( TableModel model , Column arg1 ) {
		// TODO Auto-generated method stub
		HtmlBuilder html = new HtmlBuilder();
		html.td ( 0 ).xclose ( ) ;
		try {
			StringBuffer params = new StringBuffer();
			Object bean = model.getCurrentRowBean();
			String bizTypeId = BeanUtils.getProperty( bean, "bizTypeId" ); 
			//String bizTypeKey = BeanUtils.getProperty (  bean  , "bizTypeKey" ) ;
			
			params.append (  bizTypeId  ) ; 
			
			Limit limit = model.getLimit ( );
			int curPage = limit.getPage();
			params.append ( "&ec_p=" ).append ( curPage ) ; 
			Sort sort = limit.getSort ( );
			if ( sort.getProperty ( ) != null ) {
				params.append ( "&" ).append ( "ec_s_" + sort.getProperty ( ) );
				params.append ( "=" ).append ( sort.getSortOrder ( ) ) ;
			}
			html.a( "javascript:toMod( '" + params + "' )" );
			html.xclose ( );
			html.img ( model.getContext().getContextPath() + "/themes/styles/default/images/edit.gif" , "编辑" ) ; 
			html.aEnd ( );
			
			params = new StringBuffer( ) ;
			params.append (  bizTypeId  ) ; 
			html.a( "javascript:toDet( '" + params + "' )" );
			html.xclose ( );
			html.img ( model.getContext().getContextPath() + "/themes/styles/default/images/details.gif" , "查看明细" ) ; 
			html.aEnd ( );
			
			
		} catch (Exception e) {
			logger.error ( e.getMessage ( ) , e ) ;
		}
		html.tdEnd ( );
		return html.toString();	
		}
	}

